// 原材料出库查询 -- wzhg
import React, { Component } from 'react'
import {ListBox} from '../../../components'
import { fetchData } from '../../../components/AjaxConsumer'
import { Modal } from 'antd';

export default class SearchRawHandOutSn extends Component{
    constructor(props) {
        super(props);
        //行操作列表-已弃用
        this.rowOperation = [
            
        ];
        //header 操作列表111
        this.headerOperation = [
            // {
            //     handleName: 'add',
            //     showName: '新增',
            //     iconClass: 'plus'
            // },{
            //     handleName: 'edit',
            //     showName: '修改',
            //     iconClass: 'edit'
            // },{
            //     handleName: 'delete',
            //     showName: '删除',
            //     iconClass: 'delete'
            // }
        ];

        //table列表展示列配置
        //showName、columnName 必有属性， columnWidth 可选，默认100, columnHidden: true 列隐藏
        // foreverHidden永久隐藏
        this.tableColumn = {
            storageKey: 'ListProductStorageTypeColumnConfig',
            data: [
                {
                    showName: 'id',
                    columnName: 'requisitionId',
                    columnHidden:true,
                    foreverHidden: true
                },
                {
                    showName: '出库单号',
                    columnName: 'handOutNo'
                },
                {
                    showName: '条码',
                    columnName: 'barcode'
                },
                {
                    showName: '型号',
                    columnName: 'model'
                },
                {
                    showName: '型号描述',
                    columnName: 'modelDesc',
                    columnWidth: 150
                },
                {
                    showName: '型号类型',
                    columnName: 'modelType'
                },
                {
                    showName: '单位',
                    columnName: 'unit'                  
                },
                {
                    showName: '数量',
                    columnName: 'amount',
                    columnWidth: 80
                },
                {
                    showName: '是否退扫',
                    columnName: 'scanStatus',
                    columnWidth: 100,
                    showOption: [
                        {
                            optionKey: '0',
                            optionShow: '正常'
                        },{
                            optionKey: '1',
                            optionShow: '退扫'
                        }
                    ]
                },
                {
                    showName: '扫描时间',
                    columnName: 'gmtCreate',
                    columnWidth: 140
                },
                {
                    showName: '扫描人',
                    columnName: 'createBy',
                    columnWidth: 100
                }
            ]
        };

        //搜索属性配置，如果字段不配置，默认是input搜索
        // 搜索类型：
        //      1、输入框 type='input'， 默认
        //      2、时间 type='date'
        //      3、数字 type='number'
        //      4、下拉框 type='select'
        this.searchComponentData = [
            {
                showName: '型号类型',
                name: 'modelType',
                type: 'select',
                optionList: [//下拉框的信息
                ]
            },
            {
                showName: '数量',
                name:'amount',
                type: 'number',
                maxName:'amountMax', //最大值
                minName:'amountMin'  //最小值
            },
            {
                showName:'计划日期',
                name:'gmtCreate',
                type: 'date',
                maxName:'gmtCreateMax',
                minName:'gmtCreateMin'
            },
            {
                showName:'是否退扫',
                name:'scanStatus',
                type: 'select',
                optionList:[
                    {
                        optionkey:'',
                        optionShow:''
                    },
                    {
                        optionkey:'0',
                        optionShow:'正常'
                    },{
                        optionkey:'1',
                        optionShow:'退扫'
                    }
                ]
            }
        ];

    }

    // 行操作
    rowHandles = (strHandles, rowObj) => {
       
    }

    componentWillMount() {
        const dicType = 'model_type';
        const options = {
            url: '/base/dic/get/' + dicType,
            type: 'get',
            condition: {}
        };
        //先写死，后面再改
        fetchData(this, options, this.dicInitCallBackHandle);
    }

    //下拉框 初始化
    dicInitCallBackHandle = (resData) => {
        //alert('resData' + JSON.stringify(resData, null, 4));
        let optionList = [];
        let tmp = {};
        tmp.optionKey = '';
        tmp.optionShow = '';
        optionList.push(tmp);
        resData.data.map((e, index) => {
            let tmp = {};
            tmp.optionKey = e.dicCode;
            tmp.optionShow = e.dicName;
            optionList.push(tmp);
        });
        //alert('optionList' + JSON.stringify(optionList, null, 4));
        this.tableColumn.data[5].showOption = optionList;
        this.searchComponentData[0].optionList = optionList;
        //this.setState({
        //    tableColumn: this.tableColumn,
        //    searchComponentData: this.searchComponentData
        //})
    }
    
  

    //刷新列表
    refreshHandle = () => {
        this.refs.rawOutSnQueryList.refreshHandle();
    }

    render() {
        //当左侧隐藏时，列表宽度加上左侧的宽度，
        //1、当前this.props.isHideLeft 是从页面组件containers/Main/main.js传过来
        //2、this.props.isHideLeft 最顶级赋值是在页面 containers/Main/main.js
        let isHideLeft = this.props.isHideLeft;

        return(
            <div>
                <ListBox
                    ref = 'rawOutSnQueryList'
                    title="手工出库明细查询"
                    isHideLeft={isHideLeft}
                    tableColumnData = {this.tableColumn}
                    searchComponentData={this.searchComponentData}
                    url = '/material/raw/rawHandOutSn/list'
                    rowHandles = {this.rowHandles}
                    rowOperation = {this.rowOperation}
                    headerOperation = {this.headerOperation}
                    isRowSingle = "true"
                />
            </div>
        )
        
    }

}